/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BJBots;

import Game.BJGame;
import Game.PlayerBJ;

/**
 * Class Bot Player of BlackJack Game
 * @author escabia
 */
public class BotPlayerBJ extends PlayerBJ{

    /**
     * 
     * @param id player
     */
    public BotPlayerBJ(String id){
        super(id);
    }
    
   /**
     * This method makes turn of player
     * @param currentGame 
     */
    @Override
    public void myTurn(BJGame currentGame){
        printoption('B');
        
        switch (decisionStand()){
            case 1:
                break;
            case 2:
                if(this.getSplit()){
                    printwhere();
                }                
                switch(decisionHand()){
                    case 1:
                        this.addCardToHand(currentGame.getDeck().takeCard());
                        currentGame.printstate();
                        if(points() < 21)
                            this.myTurn(currentGame); 
                        break;
                    case 2:
                        this.addCardToExtraHand(currentGame.getDeck().takeCard());
                        currentGame.printstate();
                        if(extrapoints() < 21)
                            this.myTurn(currentGame);  
                        break;
                    default:
                        System.out.println("Not a valid option1.");
                        break;
                }

                break;
            default:
                System.out.println("Not a valid option2.");
                break;
        }        
    }
    /** Method to implements strategies */
    
    /**
     * Method to decide split
     * @param number of card
     * @return option to split (1 if don't split. 2 if split)
     */
    public int decisionSplit(int number){
        int option;
        if(number == 8 || number == 11)
            option = 2;
        else if(number == 10)
            option = 1;
        else{
            option = (Math.random()<0.5)?0:1 + 1;
        }
        return option;
    }
    
    /**
     * Method to decide stand
     * @return option to stand (1 if don't stand. 2 if stand)
     */
    public int decisionStand(){
        int option = 1;
        if(points() < 8){
            option = 2;
        }
        else if(points() < 17){
            option = (Math.random()<0.5)?1:2 ;
        }
        return option;
    }
    
    /**
     * Method to decide to choose hand
     * @return decision (1 if you choose left. 2 if you choose right).
     */
    public int decisionHand(){
        return (Math.random()<0.5)?1:2 ;

    }   
}
